﻿using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Web;

namespace scmsByAspdNet.cotro.teacher {
  /// <summary>
  /// updateStudentSC 的摘要说明
  /// </summary>
  public class updateStudentSC : IHttpHandler {

    public void ProcessRequest(HttpContext context) {
      context.Response.ContentType = "text/plain";

      //获取请求参数
      string stu_id = context.Request["stu_id"];
      string cour_id = context.Request["cour_id"];
      string daily_grade = context.Request["daily_grade"];
      string terminal_grade = context.Request["terminal_grade"];
      string ultimate_grade = context.Request["ultimate_grade"];

      SqlConnection conn = new SqlConnection("Data Source=106.54.69.143;database=scms;uid=sa;pwd=Aspdotnet666");
      conn.Open();
      //更新数据sql
      SqlCommand sql_total = new SqlCommand("UPDATE sc_cour_stu" +
        " SET daily_grade="+daily_grade+"" +
        " ,terminal_grade="+terminal_grade+"" +
        " ,ultimate_grade="+ultimate_grade+"" +
        " ,submit_flag=0" +
        " WHERE cour_id="+cour_id+" AND" +
        " stu_id="+stu_id+" AND" +
        " submit_flag=1",conn);
      int res = sql_total.ExecuteNonQuery();
      conn.Close();
      //返回数据
      context.Response.StatusCode = 200;
      context.Response.Write($"{{\"line\":{res}}}");


    }

    public bool IsReusable {
      get {
        return false;
      }
    }
  }
}